package com.sys.sprinngboot.goodtheater.dao;

import com.sys.sprinngboot.goodtheater.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 获取所有用户
     *
     * @return
     */
    @Select("select * from user")
    List<User> getUsers();

    /**
     * 根据id查询用户
     *
     * @param id
     * @return
     */
    @Select("select * from user where id=#{id}")
    User getUserById(Integer id);

    /**
     * 根据email查询用户
     *
     * @param email
     * @return
     */
    @Select("select * from user where email=#{email}")
    User getUserByEmail(String email);

    /**
     * 保存用户
     *
     * @param user
     */
    @Insert("insert into user(nickname,email,password,phone,gender,role) values(#{nickname},#{email},#{password},#{phone},#{gender},#{role})")
    void saveUser(User user);
}